package org.ly.uap.client.authentication;

import java.io.Serializable;
import java.security.Principal;

import org.ly.uap.client.util.CommonUtils;

public class SimplePrincipal
        implements Principal, Serializable {
    private static final long serialVersionUID = -5645357206342793145L;
    private final String name;

    public SimplePrincipal(String name) {
        this.name = name;
        CommonUtils.assertNotNull(this.name, "name cannot be null.");
    }

    public final String getName() {
        return this.name;
    }

    public String toString() {
        return getName();
    }

    public boolean equals(Object o) {
        if (o == null)
            return false;
        if (!(o instanceof SimplePrincipal)) {
            return false;
        }
        return getName().equals(((SimplePrincipal) o).getName());
    }

    public int hashCode() {
        return 37 * getName().hashCode();
    }
}





